import Api from "../../api"

const state = {
    menu: []
}

const mutations = {
    setMenu(state, menuList) {
        state.menu = menuList
    }
}

const actions = {
    QueryMenuList({ commit }) {
        return new Promise((resolve, reject) => {
            setTimeout(async () => {
                let { data } = await Api.Menu.list().catch(error=> reject(error))
                commit('setMenu', data.data)
                resolve(data.data);
            }, 100)
        })
    },
    QueryRootNode({commit}){
        return new Promise((resolve,reject) => {
            setTimeout(async ()=>{
                let {data} = await Api.Menu.queryRootNode().catch(error => reject(error))
                resolve(data.data)
            },100)
        })
    }
}

const getters = {

}

export default {
    state, mutations, actions, getters
}